package com.wc.codeforces.树状数组.Counting_Pairs;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/1/3 15:21
 * @description
 * https://codeforces.com/contest/2051/problem/D
 */
public class Main {
    /**
     * 思路：
     * 树状数组: 保存前面 <= 的元素个数
     * 离散化: 将超出 N 的数离散化到正常的值当中
     * 二分: 在离散化中找到正常的值
     * sum - a[i] - a[j] >= x => a[i] <= sum - a[j] - x;
     * sum - a[i] - a[j] <= y => a[i] >= sum - a[j] - y
     * 遍历 a[j], 找到 树状数组中 <= sum - a[j] - x 并且 >= sum - a[j] - y 的个数也就是答案
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010;
    static int[] a = new int[N], c = new int[N], lower = new int[N];
    static int n, m;
    static long x, y;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            x = sc.nextLong();
            y = sc.nextLong();
            for (int i = 1; i <= n; i++) c[i] = a[i] = sc.nextInt();
            Arrays.sort(c, 1, n + 1);
            Arrays.fill(lower, 1, n + 1, 0);
            // 离散化
            m = 1;
            for (int i = 1; i <= n; i++) if (c[i] != c[m]) c[++m] = c[i];
            // 求和
            long sum = 0;
            for (int i = 1; i <= n; i++) sum += a[i];

            // 遍历, 求位置, 求和, 插入
            long res = 0;
            for (int i = 1; i <= n; i++) {
                long p = sum - a[i] - x, q = sum - a[i] - y;

                int r = findL(p);
                if (r == -1) continue;
                int l = findR(q);
                if (l == -1) continue;

                res += sum(r) - sum(l - 1);

                add(findL(a[i]), 1);
            }
            out.println(res);
        }
        out.flush();
    }

    static int findL(long x) {
        int l = 1, r = m;
        while (l < r) {
            int mid = l + r + 1 >> 1;
            if (c[mid] <= x) l = mid;
            else r = mid - 1;
        }
        return c[l] <= x ? l : -1;
    }

    static int findR(long x) {
        int l = 1, r = m;
        while (l < r) {
            int mid = l + r >> 1;
            if (c[mid] >= x) r = mid;
            else l = mid + 1;
        }
        return c[l] >= x ? r : -1;
    }

    static void add(int x, int c) {
        for (int i = x; i <= m; i += lowbit(i)) {
            lower[i] += c;
        }
    }

    static int lowbit(int x) {
        return x & -x;
    }

    static int sum(int x) {
        int res = 0;
        for (int i = x; i >= 1; i -= lowbit(i)) res += lower[i];
        return res;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

